package cn.talkimages.web.admin.actions;

import cn.talkimages.framework.utils.string.StringUtil;
import cn.talkimages.web.WebNavAction;
import cn.talkimages.web.admin.constant.ConfkeyDef;
import cn.talkimages.web.beans.AdminBean;

public class WebAdminAction extends WebNavAction {

	private static final long serialVersionUID = 9003433565293493652L;

	// ------------------- Common Methods ------------------- //

	/**
	 * 取得登陆用户信息
	 * 
	 * @return AdminBean
	 */
	public AdminBean getLoginUser() {
		AdminBean admin = new AdminBean();

		// TODO mock
		admin.setLoginId("admin");

		return admin;
	}

	/**
	 * 获得图片完整URL
	 * 
	 * @param dir
	 * @param imageName
	 * @return String
	 */
	public final String getImageURL(String dir, String imageName) {
		if (StringUtil.isBlank(dir) || StringUtil.isBlank(imageName))
			return "";

		return getImageURL(dir + "/" + imageName);
	}

	/**
	 * 获得图片完整URL
	 * 
	 * @param imagePath
	 * @return String
	 */
	public final String getImageURL(String imagePath) {

		if (StringUtil.isBlank(imagePath))
			return "";

		String prefix = getConfStrValue(ConfkeyDef.Pic.IMAGE_URL_PREFIX);

		return prefix + "/" + imagePath;
	}
}
